package com.bdqn.controller;

import com.bdqn.pojo.LeaveRecords;
import com.bdqn.service.LeaveRecordsService;
import com.bdqn.util.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * @author cuishujian
 * @date 2025/1/4
 */
@Controller
public class IndexController {

    @Resource
    private LeaveRecordsService leaveRecordsService;

    @RequestMapping("/index")
    public String index(@RequestParam(defaultValue = "1",required = false) Integer pageIndex, Model model){
        Page<LeaveRecords> page = new Page<LeaveRecords>();
        page.setPageSize(5);
        page.setTotalCount(leaveRecordsService.count());
        page.setPageNo(pageIndex);
        page.setData(leaveRecordsService.selectPage(page));
        model.addAttribute("page",page);
        return "home";
    }
}
